package com.wisdytech.ccdserver.matchwarning.api.impl;

import com.wisdytech.ccdserver.matchwarning.api.ICcdWarningMatchMngService;
import com.wisdytech.ccdserver.matchwarning.model.WarningMesSandstone;
import com.wisdytech.ccdserver.matchwarning.serveice.*;
import com.wisdytech.ccdserver.matchwarning.vo.WarningEquipmentVo;
import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.MultiResultResponse;
import com.wisdytech.common.bean.UniqueResultResponse;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author sunjinxin
 * @date 2024/5/20
 */

@DubboService
public class CcdWarningMatchMngServiceImpl implements ICcdWarningMatchMngService {


    @Autowired
    private IWarningEquipmentService warningEquipmentService;

    @Autowired
    private IWarningMesSandstoneService warningMesSandstoneService;


    @Autowired
    private IWarningMesProductionService warningMesProductionService;

    @Autowired
    private IWarningMatchService warningMatchService;

    @Autowired
    private IWarningSandstoneImageService warningSandstoneImageService;

    @Override
    public MultiResultResponse getWarningEquipmentList(Filter filter) throws Exception {

        return MultiResultResponse.success(warningEquipmentService.getWarningEquipmentList(filter));
    }

    @Override
    public MultiResultResponse getWarningMesSandstoneList(Filter filter) throws Exception {
        return MultiResultResponse.success(warningMesSandstoneService.getWarningMesSandstoneList(filter));
    }

    @Override
    public MultiResultResponse getWarningMesProductionList(Filter filter) throws Exception {
        return MultiResultResponse.success(warningMesProductionService.getWarningMesProductionList(filter));
    }

    @Override
    public MultiResultResponse getWarningMatchList(Filter filter) throws Exception {
        return MultiResultResponse.success(warningMatchService.getWarningMatchList(filter));
    }

    @Override
    public MultiResultResponse getWarningSandstoneImageList(Filter filter) throws Exception {
        return MultiResultResponse.success(warningSandstoneImageService.getWarningSandstoneImageList(filter));
    }

    @Override
    public UniqueResultResponse<Boolean> saveOrUpdateWarningMesSandstone(WarningMesSandstone warningMesSandstone) {
        String username = RpcContext.getContext().getAttachment("username");
        return UniqueResultResponse.success(warningMesSandstoneService.saveWarningMesSandstone(warningMesSandstone,username));
    }

    @Override
    public UniqueResultResponse<Boolean> saveOrUpdateWarningEquipment(WarningEquipmentVo warningEquipmentVo) {
        String username = RpcContext.getContext().getAttachment("username");
        return UniqueResultResponse.success(warningEquipmentService.saveWarningEquipment(warningEquipmentVo,username));
    }

    @Override
    public UniqueResultResponse countMatch(Filter filter) throws Exception {
        warningMatchService.countMatch();
        return UniqueResultResponse.success("");
    }
}
